package serializer

import (
	"go-shop-api/internal/model"
	"go-shop-api/pkg/funs"
)

// BannerVo 信息
type BannerVo struct {
	ID     uint   `json:"id" _:"comment:id"`
	Title  string `json:"title" _:"comment:标题"`
	Desc   string `json:"desc" _:"comment:描述"`
	Images string `json:"images" _:"comment:图片地址"`
	Url    string `json:"url" _:"comment:是否有跳转地址"`
	Scene  uint   `json:"scene" _:"comment:场景 0未知 1 首页轮播图"`
}

func BuildBanner(item *model.Banner) *BannerVo {
	return &BannerVo{
		ID:     item.ID,
		Title:  item.Title,
		Desc:   item.Desc,
		Images: funs.JointImageUrl(item.Images),
		Url:    item.Url,
		Scene:  item.Scene,
	}
}

func BuildListBanner(items []*model.Banner) (list *[]*BannerVo) {
	var tempList []*BannerVo
	for _, item := range items {
		temp := BuildBanner(item)
		tempList = append(tempList, temp)
	}
	return &tempList
}
